<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    let str = "  a b c de fj ";
    //前面
    function fn() {
        let a = str.replace(/^\s+/, "")
        console.log(a);
    }
    //后面
    function fn1() {
        let a = str.replace(/\s+$/, "")
        console.log(a);
    }
    //前后
    function fn2() {
        let a = str.replace(/(^\s+)|(\s+$)/g, "")
        console.log(a);
    }
    //所有
    function fn3() {
        let a = str.replace(/\s/g, "")
        console.log(a);
    }
    fn()
    fn1()
    fn2()
    fn3()
    //验证手机号
    function fn4() {
        let reg = /^1[34578]\d{9}$/
        let str1 = "17356527292"
        console.log(str1);
        let flag = reg.test(str1)
        console.log(flag);
    }
    fn4()
    //验证邮箱
    function fn5() {
        let reg = /^[a-zA-Z0-9]+@[a-zA-Z0-9]{2,}(\.com|\.cn|\.com\.cn|\.org|\.net|\.edu)$/
        let str2 = "1025127795@qq.com"
        console.log(str2);
        let flag = reg.test(str2)
        console.log(flag);
    }
    fn5()
</script>

</html>